﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Demo.Services.Contracts.DTO.Infos;
using Demo.Services.Contracts.DTO.Filters;
using Demo.Services.Services.Impl.DomainObjects;
using Demo.CommonBase.Logging;
using Demo.CommonBase.Exceptions;
using System.Reflection;

namespace Demo.Services.Services.Impl.Managers
{
    public class OperationManager
    {

        public OperationPagingInfo GetOperations(OperationFilter filter)
        {
            OperationPagingInfo result = null;
            OperationDomainObject operationDO;
            try
            {
                Logger.Info();
                operationDO = new OperationDomainObject();
                result = operationDO.GetOperations(filter);
            }

            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new UnhandledException(MethodInfo.GetCurrentMethod(), ex);
            }
            return result;
        }

        public ResourcePagingInfo GetOperationResources(ResourceFilter filter)
        {
            ResourcePagingInfo result = null;
            OperationDomainObject operationDO;
            try
            {
                Logger.Info();
                operationDO = new OperationDomainObject();
                result = operationDO.GetOperationResources(filter);
            }

            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new UnhandledException(MethodInfo.GetCurrentMethod(), ex);
            }
            return result;
        }

        public ResourceInfo GetResourceLineTime(int id)
        {
            ResourceInfo result = null;
            OperationDomainObject operationDO;
            try
            {
                Logger.Info();
                operationDO = new OperationDomainObject();
                result = operationDO.GetResourceLineTime(id);
            }

            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new UnhandledException(MethodInfo.GetCurrentMethod(), ex);
            }
            return result;
        }

        public void SaveLineTime(LineTimeInfo lineTime)
        {
            OperationDomainObject operationDO;
            try
            {
                Logger.Info();
                operationDO = new OperationDomainObject();
                operationDO.SaveLineTime(lineTime);
            }
            catch (AbstractException)
            {
                throw;
            }


            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new UnhandledException(MethodInfo.GetCurrentMethod(), ex);
            }
        }

        public void UpdateLineTime(LineTimeInfo lineTime)
        {
            OperationDomainObject operationDO;
            try
            {
                Logger.Info();
                operationDO = new OperationDomainObject();
                operationDO.UpdateLineTime(lineTime);
            }

            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new UnhandledException(MethodInfo.GetCurrentMethod(), ex);
            }
        }

        public void DeleteLineTime(int id)
        {
            OperationDomainObject operationDO;
            try
            {
                Logger.Info();
                operationDO = new OperationDomainObject();
                operationDO.DeleteLineTime(id);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new UnhandledException(MethodInfo.GetCurrentMethod(), ex);
            }
            
        }

        public void DeleteOperationLineTime(int id)
        {
            OperationDomainObject operationDO;
            try
            {
                Logger.Info();
                operationDO = new OperationDomainObject();
                operationDO.DeleteOperationLineTime(id);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new UnhandledException(MethodInfo.GetCurrentMethod(), ex);
            }

        }
    }
}
